#!/bin/sh
#
# Test the fill command in btape
#
TestName="btape-fill-full-changer"
JobName=btape-fill-changer
. scripts/functions

require_tape_drive
require_autochanger

scripts/cleanup
scripts/copy-btape-confs

change_jobname $JobName
start_test

#
#  Increase block size to 262144
#
cp ${cwd}/bin/susan-sd.conf ${cwd}/tmp/1
sed -e 's%64512%262144%' ${cwd}/tmp/1 >${cwd}/bin/susan-sd.conf
#
# Limit Volume size for debugging without waiting too long
#
# cp ${cwd}/bin/susan-sd.conf ${cwd}/tmp/1
# sed -e 's%# MaximumVolumeSize = 400M%  MaximumVolumeSize = 400M%' ${cwd}/tmp/1 >${cwd}/bin/susan-sd.conf

if test "$debug" -eq 1 ; then
   $bin/btape -c bin/susan-sd.conf Drive-0 <<END_OF_DATA | tee ${cwd}/tmp/log1.out
fill
m

quit
END_OF_DATA
else
   $bin/btape -c bin/susan-sd.conf Drive-0 <<END_OF_DATA >${cwd}/tmp/log1.out 2>&1
fill
m

quit
END_OF_DATA
fi

grep "^The last block on the second tape matches\. Test succeeded\." ${cwd}/tmp/log1.out >/dev/null 2>&1
if [ $? != 0 ] ; then
   echo " "
   echo " "
   echo "  !!!!! btape fill test failed!!! !!!!! "
   echo "  !!!!! btape fill test failed!!! !!!!! " >>test.out
   echo " "
else
   echo "  ===== btape fill test OK ===== "
   echo "  ===== btape fill test OK ===== " >>test.out
   scripts/cleanup
fi
